<?php
/**
 * Groups configuration for default Minify implementation
 * @package Minify
 */

/** 
 * You may wish to use the Minify URI Builder app to suggest
 * changes. http://yourdomain/min/builder/
 **/

function recScriptAdd($r_array, $r_type, $dirname, $filetype)
{
    
    if ($handle = opendir($r_type . DS . $dirname))
    {
        
        while(false !== ($file = readdir($handle)))
        {
            
            if ((is_file($r_type . DS . $dirname . DS . $file)) && (substr($file, strrpos($file, '.')) == $filetype))
            {
                
                array_push($r_array, $r_type . DS . $dirname . DS . $file);
            
            }
            else
            {
                if (($file != '..') && ($file != '.') && (substr($file, strrpos($file, '.')) == '.svn'))
                {
                    recScriptAdd(&$r_array, $r_type, $dirname . DS . $file, $filetype);
                }
            }
        }
        closedir($handle);
    }
    sort($r_array);
    return $r_array;
}

$template = preg_replace('%[^\w_-]+%i', '', $_GET['t']);
$group = preg_replace('%[^\w_-]+%i', '', $_GET['g']);

if (! $template || ! is_dir('templates' . DS . $template))
    $template = '_core';
$template = 'templates' . DS . $template;

switch ($group)
{
    case 'js' :
        $filetype = '.js';
        $folder = 'js';
    break;
    
    case 'adminjs' :
        $filetype = '.js';
        $template = 'templates' . DS . '_admin';
        $folder = 'js';
    break;
    
    case 'css' :
        $filetype = '.css';
        $folder = 'css';
    break;
    case 'adminjs_od' :
        $admin_page = preg_replace('%[^\w_-]+%i', '', $_GET['ap']);
        $template = 'templates' . DS . '_admin'.DS.'js_od';
        $folder = $admin_page;
        $filetype = '.js';
        
        if(!is_dir($template.DS.$folder))
        {
            exit();
        }

    
    break;
    case 'admincss' :
    default :
        $filetype = '.css';
        $template = 'templates' . DS . '_admin';
        $folder = 'css';
    break;

}

$return_array = array();
$return_array = recScriptAdd($return_array, $template, $folder, $filetype);
sort($return_array);


return array(
        $group => $return_array
);

